$(function(){
	
		
		$("#pro-sel-ul li").on("mouseenter",function(){
			$(this).addClass("hover").siblings().removeClass("hover");
			var which = $(this).index();
			$("#pro-sel-show .pro-sel-show-item")
			.eq(which).removeClass("hide")
			.siblings().addClass("hide");
		});
	

	$("#pro-sel").on("mouseleave",function(){
		$("#pro-sel-ul li").removeClass("hover");
		$("#pro-sel-show .pro-sel-show-item").addClass("hide");
	});


	//这下面开始轮播图代码
	var timer = null;
	var index = 1;
	var curindex = 0;
	var flag = true;

	//首尾加一张，形成无缝
	var len = $("#lunbotu li").length;
	$("#lunbotu").prepend($("#lunbotu li").eq(len-1).clone(true));
	$("#lunbotu").append($("#lunbotu li").eq(1).clone(true));

	//正常的向右播放代码
	function play(){
		clearTimeout(timer);
            index++;
            curindex++;
            $("#lunbotu").css({
            	"transition": "all 1s ease",
				"transform": "translate3d("+(-1200*index)+"px,0,0)"
			});

			if(curindex == 3){
                curindex = 0;
            }

            selcar(curindex);
         
            	$("#lunbotu").on("transitionend",function(){
            		//从边界到边界过渡以后切回正确位置
                if (index == 4){
                    index = 1;
                    $("#lunbotu").css({
						"transition": "none",
						"transform": "translate3d("+(-1200*index)+"px,0,0)"
					});
                }
				flag = true;

            	});
                
          
           timer = setTimeout(play,2000);        
        }

     //这个轮播图控制圆点的代码
    function selcar(index){
    	$("#car-cont span").eq(index).addClass("cur").siblings().removeClass("cur");
    }    


	timer = setTimeout(play,2000);


	//大盒子移入清除定时器，移开触发定时器
	$("#car-show").on("mouseenter",function(){
		clearTimeout(timer);
	});
	$("#car-show").on("mouseleave",function(){
		timer = setTimeout(play,2000);
	});

	//圆点点击切换
	$("#car-cont span").on("click",function(){
		index = $(this).index()+1;
		curindex = $(this).index();
		 $("#lunbotu").css({
            	"transition": "all 1s ease",
				"transform": "translate3d("+(-1200*index)+"px,0,0)"
		});
		 selcar(curindex);
	});

	//点击右边按钮，切换下一张，就这个开始出问题
	$("#car-next").on("click",function(){
		if(flag){
			play();
			flag = false;
		}
		
	});


})